Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

big-integer

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

big-integer

An arbitrary length integer library for Javascript

  • 1.6.52
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11M
increased by2.84%
Maintainers
1
Weekly downloads
 
Created

What is big-integer?

The big-integer npm package is designed for arithmetic and logical operations on large integers beyond the safe limit for JavaScript's native number type. It provides a way to work with integers of arbitrary size, allowing for precise calculations that would otherwise be impossible due to the limitations of standard number precision in JavaScript.

What are big-integer's main functionalities?

Arithmetic Operations

Demonstrates basic arithmetic operations such as addition, subtraction, multiplication, division, and modulo on large integers.

"use strict";\nconst bigInt = require('big-integer');\nlet x = bigInt('123456789012345678901234567890');\nlet y = bigInt('98765432109876543210987654321');\nlet sum = x.add(y);\nlet difference = x.minus(y);\nlet product = x.multiply(y);\nlet quotient = x.divide(y);\nlet remainder = x.mod(y);\nconsole.log('Sum:', sum.toString());\nconsole.log('Difference:', difference.toString());\nconsole.log('Product:', product.toString());\nconsole.log('Quotient:', quotient.toString());\nconsole.log('Remainder:', remainder.toString());

Logical Operations

Shows how to perform bitwise logical operations such as AND, OR, and XOR on large integers.

"use strict";\nconst bigInt = require('big-integer');\nlet x = bigInt('12345678901234567890');\nlet y = bigInt('9876543210987654321');\nlet andResult = x.and(y);\nlet orResult = x.or(y);\nlet xorResult = x.xor(y);\nconsole.log('AND:', andResult.toString());\nconsole.log('OR:', orResult.toString());\nconsole.log('XOR:', xorResult.toString());

Comparison Operations

Illustrates how to compare two large integers, checking for greater than, less than, and equality.

"use strict";\nconst bigInt = require('big-integer');\nlet x = bigInt('12345678901234567890');\nlet y = bigInt('9876543210987654321');\nconsole.log('x > y:', x.greater(y));\nconsole.log('x < y:', x.lesser(y));\nconsole.log('x == y:', x.equals(y));

Other packages similar to big-integer

Keywords

FAQs

Package last updated on 21 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc